package com.bolt.report.definition;

import com.bolt.report.definition.PaperSize.SizeUnit;
import com.bolt.report.exception.ReportException;

import java.io.Serializable;

public enum PaperType implements Serializable {

    A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10,CUSTOM;

    public PaperSize getPaperSize(){
        switch(this){
            case A0:
                return new PaperSize(841,1189, SizeUnit.MM);
            case A1:
                return new PaperSize(594,841, SizeUnit.MM);
            case A2:
                return new PaperSize(420,594, SizeUnit.MM);
            case A3:
                return new PaperSize(297,420, SizeUnit.MM);
            case A4:
                return new PaperSize(210,297, SizeUnit.MM);
            case A5:
                return new PaperSize(148,210, SizeUnit.MM);
            case A6:
                return new PaperSize(105,148, SizeUnit.MM);
            case A7:
                return new PaperSize(74,105, SizeUnit.MM);
            case A8:
                return new PaperSize(52,74, SizeUnit.MM);
            case A9:
                return new PaperSize(37,52, SizeUnit.MM);
            case A10:
                return new PaperSize(26,37, SizeUnit.MM);
            case B0:
                return new PaperSize(1000,1414, SizeUnit.MM);
            case B1:
                return new PaperSize(707,1000, SizeUnit.MM);
            case B2:
                return new PaperSize(500,707, SizeUnit.MM);
            case B3:
                return new PaperSize(353,500, SizeUnit.MM);
            case B4:
                return new PaperSize(250,353, SizeUnit.MM);
            case B5:
                return new PaperSize(176,250, SizeUnit.MM);
            case B6:
                return new PaperSize(125,176, SizeUnit.MM);
            case B7:
                return new PaperSize(88,125, SizeUnit.MM);
            case B8:
                return new PaperSize(62,88, SizeUnit.MM);
            case B9:
                return new PaperSize(44,62, SizeUnit.MM);
            case B10:
                return new PaperSize(31,44, SizeUnit.MM);
            default:
                throw new ReportException("Unsupport "+this+" paper.");
        }
    }

}